﻿using System.Threading.Tasks;

namespace Anay.TaskScheduling.Common
{
    public class TaskScheduingHepler
    {
        QuartzHelper QuartzHelper = new QuartzHelper();
        IConfigHelper ConfigHelper = new ConfigFactory().GetInstance();
        Quartz.IJob job = new JobFactory().GetInstance();

        public async Task TaskScheduingRun()
        {

            var TaskConfigList = ConfigHelper.GetTaskConfigList();
            if (TaskConfigList.Count > 0)
            {
                foreach (var TaskConfig in TaskConfigList)
                {
                    if (TaskConfig.TimeType.ToUpper() == "TIGGER")
                    {
                        await QuartzHelper.SimpleTriggerRunAsync(job, TaskConfig);
                    }
                    else
                    {
                        await QuartzHelper.CronTriggerRun(job, TaskConfig);
                    }

                }
            }
        }
    }
}

